package main

import (
	"fmt"
	"regexp"
	"strings"
)

func solution(n int, template_ string, titles []string) string {
	// 将模板中的通配符替换为正则表达式中的任意字符匹配模式
	pattern := regexp.MustCompile(`\{.*?\}`).ReplaceAllString(template_, ".*")
	// 编译正则表达式模式
	regex := regexp.MustCompile("^" + pattern + "$")

	// 对每个标题进行匹配，并将结果转换为字符串列表
	var result []string
	for _, title := range titles {
		result = append(result, fmt.Sprintf("%t", regex.MatchString(title)))
	}
	// 将结果列表用逗号连接成一个字符串
	return strings.Join(result, ",")
}

func main() {
	testTitles1 := []string{"adcdcefdfeffe", "adcdcefdfeff", "dcdcefdfeffe", "adcdcfe"}
	testTitles2 := []string{"CLSomGhcQNvFuzENTAMLCqxBdj", "CLSomNvFuXTASzENTAMLCqxBdj",
		"CLSomFuXTASzExBdj", "CLSoQNvFuMLCqxBdj", "SovFuXTASzENTAMLCq", "mGhcQNvFuXTASzENTAMLCqx"}
	testTitles3 := []string{"abcdefg", "abefg", "efg"}

	fmt.Println(solution(4, "ad{xyz}cdc{y}f{x}e", testTitles1) == "true,false,false,true")
	fmt.Println(solution(6, "{xxx}h{cQ}N{vF}u{XTA}S{NTA}MLCq{yyy}", testTitles2) == "false,false,false,false,false,true")
	fmt.Println(solution(3, "a{bdc}efg", testTitles3) == "true,true,false")
}
